<template>
  <div>
    <!-- <el-button type="primary" @click="EWdialogVisible = true">
      一级预警
    </el-button> -->
    <div class="collocateHome">
      <div class="box-card" @click="dialogVisible = true">
        <el-card class="add-basiness">
          <p class="el-icon-plus">
            添加业务
          </p>
        </el-card>
      </div>
      <div class="box-card">
        <!-- <el-card>1</el-card> -->
      </div>
    </div>

    <!-- 弹窗 -->
    <!-- :form-data="modalFormData"：是添加数据，不是编辑，不需要 -->
    <device-update
      title="选择业务"
      :visible.sync="dialogVisible"
      :before-close="() => (dialogVisible = false)"
      :handle-submit="handleModalSubmit"
      :form-data="modalFormData"
      width="400px"
    />
    <!-- 预警弹窗 -->
    <early-warning
      title="业务预警情况"
      :before-close="() => (EWdialogVisible = false)"
      :visible.sync="EWdialogVisible"
      width="1040px"
      :on-cancle="handleCancle"
      :form-data="formData"
    />
  </div>
</template>

<script>
import DeviceUpdate from './update'
import EarlyWarning from '@/components/EarlyWarning'
export default {
  components: {
    DeviceUpdate,
    EarlyWarning
  },
  data() {
    return {
      dialogVisible: false, // 弹窗的显示
      modalFormData: {}, // 弹窗表单数据
      EWdialogVisible: false, // 预警的弹窗
      formData: {
        // 预警弹窗数据
        headerData: {
          earlyWarningLevel: '一级预警',
          collectionRateValue: 0.9,
          dunningRate: '0.20',
          triggerTime: '2020-03-15'
        },
        tableData: [
          {
            No: '1',
            name: 'A区域',
            collectionRate: 0.9,
            dunningRate: '0.15',
            ownerSatisfaction: '0.7',
            workOrderRate: '0.91'
          },
          {
            No: '2',
            name: 'B区域',
            collectionRate: '0.8',
            dunningRate: '0.23',
            ownerSatisfaction: '0.98',
            workOrderRate: '0.75'
          },
          {
            No: '3',
            name: 'C区域',
            collectionRate: '0.8',
            dunningRate: '0.15',
            ownerSatisfaction: '0.7',
            workOrderRate: '0.8'
          },
          {
            No: '1',
            name: 'A区域',
            collectionRate: '0.92',
            dunningRate: '0.15',
            ownerSatisfaction: '0.7',
            workOrderRate: '0.91'
          },
          {
            No: '2',
            name: 'B区域',
            collectionRate: '0.8',
            dunningRate: '0.23',
            ownerSatisfaction: '0.98',
            workOrderRate: '0.75'
          },
          {
            No: '3',
            name: 'C区域',
            collectionRate: '0.8',
            dunningRate: '0.15',
            ownerSatisfaction: '0.7',
            workOrderRate: '0.8'
          },
          {
            No: '2',
            name: 'B区域',
            collectionRate: '0.8',
            dunningRate: '0.23',
            ownerSatisfaction: '0.98',
            workOrderRate: '0.75'
          },
          {
            No: '3',
            name: 'C区域',
            collectionRate: '0.8',
            dunningRate: '0.15',
            ownerSatisfaction: '0.7',
            workOrderRate: '0.8'
          }
        ]
      }
    }
  },
  methods: {
    handleCancle(val) {
      this.EWdialogVisible = val
    },
    onEarly() {
      console.log(1)
    },
    handleModalSubmit(val) {
      // 点击提交
      console.log(val)
      // businessCreated: "主营业务" displayTemplate: 1
      this.dialogVisible = false
    }
  }
}
</script>

<style lang="scss" scoped>
@import '../index.scss';
.collocateHome {
  display: flex;
  justify-content: space-between;
  flex-direction: row;
  flex-wrap: wrap;
  .box-card {
    width: 49.3%;
    min-width: 49.3%;
    margin: 14px 0;
    text-align: center;
    .add-basiness {
      cursor: pointer;
    }
    .el-card {
      height: 617px;
      line-height: 617px;
      font-size: 20px;
      color: #999;
      p {
        font-weight: 800;
      }
    }
  }
}
</style>
